package cn.bmyi.webautotest.baidudemo;

import cn.bmyi.webautotest.aimee.BrowserEmulator;

/**
 * 封装百度首页元素和操作
 * 
 * @author 毛建杰
 *
 */
public class HomePage
{
	public BrowserEmulator browser;
	public String url;

	private static class PageElement
	{
		public static final String SEARCH_INPUT_ID = "index-kw"; // 搜索输入框
		public static final String SEARCH_BUTTON_ID = "index-bn"; // 搜索按钮
	}

	public HomePage(BrowserEmulator browser, String url)
	{
		this.browser = browser;
		this.url = url;
		this.browser.open(this.url);
	}

	/**
	 * 输入搜索关键字
	 * 
	 * @param input
	 *            搜索关键字
	 */
	public void intputSearchKeyword(CharSequence... input)
	{
		browser.findElement("id", PageElement.SEARCH_INPUT_ID).type(input);
	}

	/**
	 * 点击百度一下按钮
	 */
	public void clickSearchButton()
	{
		browser.findElement("id", PageElement.SEARCH_BUTTON_ID).click();
	}
}
